package com.teacold.customdemo.chapter_seven;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;

import com.teacold.customdemo.R;

public class ShadowLayerView extends View {
    private Paint mPaint=new Paint();
    private Bitmap mDogBmp;

    public ShadowLayerView(Context context) {
        super(context);
        setLayerType(LAYER_TYPE_SOFTWARE,null);
        mPaint.setColor(Color.BLACK);
        mPaint.setTextSize(25);
        mPaint.setShadowLayer(1,10,10,Color.GRAY);

        mPaint.setMaskFilter(new BlurMaskFilter(50,BlurMaskFilter.Blur.INNER));//发光效果   Blur.INNER内发光 SOLID外发光 NORMAL内外发光 OUTER显示发光效果

        mDogBmp=BitmapFactory.decodeResource(getResources(), R.drawable.dog);

    }

    public ShadowLayerView(Context context, AttributeSet attrs) {
        this(context);
    }

    public ShadowLayerView(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawColor(Color.WHITE);
        canvas.drawText("启舰",100,10,mPaint);
        canvas.drawCircle(300,100,50,mPaint);
        canvas.drawBitmap(mDogBmp,null,new Rect(200,300,200+mDogBmp.getWidth(),300+mDogBmp.getHeight()),mPaint);


    }



}
